package com.wanxin.wb.module.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wanxin.wb.common.model.UserVO;
import com.wanxin.wb.common.service.IUserService;
import com.wanxin.wb.module.web.vo.SignVO;

@Controller
@RequestMapping("cn")
public class UserController {
	
	@Autowired
	private IUserService userService;
	
	@RequestMapping(value = "/login1.do")
	public ModelAndView  login1(HttpServletRequest request, HttpServletResponse response, String username,
			String password) throws Exception {
		
		//测试
		username="1";
		password="2";
		
		
		UserVO user = userService.getByAccount(username, password);
		if (user == null) {
			return null;
		}
		SignVO result = new SignVO();
		BeanUtils.copyProperties(user, result);
		
		  ModelAndView view = new ModelAndView("user");
	      view.addObject("user", result);
	        
		return view;
	}
	
	
	
	
	
/**
 * mysql
 * @param request
 * @param response
 * @param username
 * @param password
 * @return
 * @throws Exception
 */
	@RequestMapping(value = "/login2.do")
	public ModelAndView  login2(HttpServletRequest request, HttpServletResponse response, String username,
			String password) throws Exception {
		
		//测试
		username="1";
		password="2";
		
		
		UserVO user = userService.getByAccount2(username, password);
		if (user == null) {
			return null;
		}
		SignVO result = new SignVO();
		BeanUtils.copyProperties(user, result);
		
		  ModelAndView view = new ModelAndView("user");
	      view.addObject("user", result);
	        
		return view;
	}

}
